package com.elock.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.elock.base.core.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Entity - 角色
 * @author 仁德
 */
@Entity
@Table(name = "pc_role")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "pc_role_sequence")
public class PcRole extends BaseEntity {

	private static final long serialVersionUID = -6614052029623997372L;

	/** 名称 */
	private String name;

	/** 是否内置 */
	private Boolean isSystem;

	/** 描述 */
	private String description;

//	/** 机构 */
//	private SaleOrg saleOrg;

	/** pc菜单 */
	private Set<PcMenu> pcMenus = new HashSet<PcMenu>();

	/**
	 * 获取 名称
	 * @return name
	 */
	@NotEmpty
	@Length(max = 200)
	@Column(nullable = false)
	public String getName() {
		return name;
	}

	/**
	 * 设置 名称
	 * @param name 名称
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取 是否内置
	 * @return isSystem
	 */
	@Column(nullable = false, updatable = false)
	public Boolean getIsSystem() {
		return isSystem;
	}

	/**
	 * 设置 是否内置
	 * @param isSystem 是否内置
	 */
	public void setIsSystem(Boolean isSystem) {
		this.isSystem = isSystem;
	}

	/**
	 * 获取 描述
	 * @return description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * 设置 描述
	 * @param description 描述
	 */
	public void setDescription(String description) {
		this.description = description;
	}

//	/**  
//	 * 获取saleOrg  
//	 * @return saleOrg saleOrg  
//	 */
//	@ManyToOne(fetch = FetchType.LAZY)
//	public SaleOrg getSaleOrg() {
//		return saleOrg;
//	}
//
//	/**  
//	 * 设置saleOrg  
//	 * @param saleOrg saleOrg  
//	 */
//	public void setSaleOrg(SaleOrg saleOrg) {
//		this.saleOrg = saleOrg;
//	}

	/**
	 * 获取 pc菜单
	 * @return pcMenus
	 */
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "pc_menu_role")
	@JsonIgnore
	public Set<PcMenu> getPcMenus() {
		return pcMenus;
	}

	/**
	 * 设置 pc菜单
	 * @param pcMenus pc菜单
	 */
	public void setPcMenus(Set<PcMenu> pcMenus) {
		this.pcMenus = pcMenus;
	}

}
